package hydrap2p.speedlimiter;

import hydrap2p.helper.ServiceConnector;
import hydrap2p.logging.Level;
import hydrap2p.logging.Logging;

import org.apache.thrift.TException;

/**
 * Static class to help other parts log
 * @author Hufman
 *
 */
public class SpeedLimiterLogging {

	private static Logging.Client logger;
	private static long lastCheck=0;
	private static final int checkOften=10000;
	
	public static void log(Level level, String source, String reason)
	{
//		synchronized(SpeedLimiterLogging.class)
//		{
//			if (logger==null && System.currentTimeMillis()>(lastCheck+checkOften))
//			{
//				logger=ServiceConnector.getLogger();
//				lastCheck=System.currentTimeMillis();
//			}
//			if (logger==null)
//			{
//				System.err.println(source+": "+reason);
//				return;
//			}
//			
//			try {
//				logger.log(level, source, reason);
//			} catch (TException e) {
//				System.err.println(source+": "+reason);
//				logger=null;
//			}
//		}
	}
	public static void setLogger(Logging.Client logger)
	{
		SpeedLimiterLogging.logger=logger;
	}
}
